<?php 
class CustomerAction extends Action{
	public function index(){
		$this->display();
	}
	public function customer_list(){		$customer = M('customer'); // 实例化Data数据模型		$page = isset($_POST['page']) ? intval($_POST['page']) : 1;		$rows = isset($_POST['rows']) ? intval($_POST['rows']) : 10;		$offset = ($page-1)*$rows;		$result = array();		$row = mysql_fetch_assoc(mysql_query("select count(*) As Total from `customer`"));		$result['total'] = $row['Total'];		$list = mysql_query("select * from `customer` order by id desc limit $offset,$rows");		$items = array();		while($row = mysql_fetch_assoc($list)){			array_push($items, $row);		}		$result["rows"] = $items;		echo json_encode($result);	}	public function customer_save(){		$name = $_REQUEST['name'];
		$country = $_REQUEST['country'];
		$email = $_REQUEST['email'];		$tel = $_REQUEST['tel'];
		$msn = $_REQUEST['msn'];
		$skype = $_REQUEST['skype'];
		$wangwang = $_REQUEST['wangwang'];		$date = $_REQUEST['date'];		$Customer = M('customer');		$sql = "insert into customer (name,country,email,tel,msn,skype,wangwang,date) values('$name','$country','$email','$tel','$msn','$skype','$wangwang','$date')";		@mysql_query($sql);		echo json_encode(array(				'id' => mysql_insert_id(),				'name' => $name,				'country' => $country,				'email' => $email,				'tel' => $tel,				'msn' => $msn,				'skype' => $skype,
				'wangwang' => $wangwang,
				'date' => $date		));	}	public function customer_update(){		$id = intval($_REQUEST['id']);		$name = $_REQUEST['name'];
		$country = $_REQUEST['country'];
		$email = $_REQUEST['email'];
		$tel = $_REQUEST['tel'];
		$msn = $_REQUEST['msn'];
		$skype = $_REQUEST['skype'];
		$wangwang = $_REQUEST['wangwang'];
		$date = $_REQUEST['date'];
		$Customer = M('customer');		$sql = "update customer set name='$name',country='$country',email='$email',tel='$tel',msn='$msn', skype='$skype', wangwang='$wangwang' date='$date' where id=$id";		@mysql_query($sql);		echo json_encode(array(				'id' => $id,				'name' => $name,
				'country' => $country,
				'email' => $email,
				'tel' => $tel,
				'msn' => $msn,
				'skype' => $skype,
				'wangwang' => $wangwang,
				'date' => $date		));	}	public function customer_destroy(){		$id = intval($_REQUEST['id']);		$Customer = M('customer');		$sql = "delete from customer where id=$id";		@mysql_query($sql);		echo json_encode(array('success'=>true));	}
}
?>